/*
 * Copyright (c) 2017, www.zm0618.com All Rights Reserved..
 */

package com.light.hessian.exporter.registry.xml;

import com.light.hessian.exporter.registry.HessianExporterAutoRegister;
import com.light.hessian.exporter.registry.config.RegistryType;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.w3c.dom.Element;


/**
 * Created by zhaojun on 2017/02/16.
 */
public class HessianExporterRegisterBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
    @Override
    protected boolean shouldGenerateId() {
        return true;
    }

    @Override
    protected Class<?> getBeanClass(Element element) {
        return HessianExporterAutoRegister.class;
    }

    @Override
    protected void doParse(Element element, BeanDefinitionBuilder builder) {

        String namespace=  element.getAttribute("namespace");
        String registryType=element.getAttribute("registryType");
        String config=element.getAttribute("config");
        builder.addPropertyValue("nameSpace",namespace);
        builder.addPropertyValue("registryType", RegistryType.valueOf(registryType));
        builder.addPropertyValue("config",config);


    }
}
